<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->

<head>
<meta charset="utf-8">
<title>卖盘池</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta content="" name="description">
<meta content="" name="author">
<link href="${request.getContextPath()}/Public/assets/admin/css/css.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/font-awesome/css/font-awesome.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/simple-line-icons/simple-line-icons.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/css/bootstrap.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/uniform/css/uniform.default.css"
	rel="stylesheet" type="text/css">
<link rel="${request.getContextPath()}/Public/stylesheet"
	type="text/css"
	href="assets/global/plugins/jquery-notific8/jquery.notific8.min.css" />
<link
	href="${request.getContextPath()}/Public/assets/global/css/components-rounded.css"
	id="style_components" rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/css/plugins.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/layout.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/themes/default.css"
	rel="stylesheet" type="text/css" id="style_color">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/custom.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/css/kkpager.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/common.css"
	rel="stylesheet" type="text/css">
<link rel="shortcut icon"
	href="${request.getContextPath()}/Public/assets/global/plugins/datatables/media/images/favicon.ico">
<link href="${request.getContextPath()}/Public/css/customerDetail.css"
	rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/css/exportAndImport.css"
	rel="stylesheet" type="text/css">
<script>
	BASE_URL = '${request.getContextPath()}'
</script>
<script type="text/javascript" src="${request.getContextPath()}/Public/My97DatePicker/WdatePicker.js">
</script>
<style type="text/css">
body {
	margin: 0;
	padding: 0;
}
/*div_Import */
#div_Import {
	position: fixed;
	z-index: 999;
	width: 600px;
	height: 400px;
	border: 1px solid #ccc;
	background: #efefef;
	display: none;
	overflow: auto;
	border-radius:10px;
}

#div_Import .tit {
	background: #ddd;
	display: block;
	height: 15px;
	width:600px;
	margin:0 auto;
}

#div_Import .tit_NC {
	background: #26a69a;
	display: block;
	height: 24px;
}

#div_Import .tit i {
	float: right;
	line-height: 15px;
	padding: 0 8px;
	cursor: pointer;
}
.downloadLink:hover{
	text-decoration: underline;
}
</style>
</head>

<body class="page-header-top-fixed">
	<div id="div_Import">
		<div class="tit_NC">
			<i class="close">关闭</i>
		</div>
		<div style="padding:0 20px;">
			<p style="padding-top:20px;"><b>请选择导入的excel文件：</b></p>
			<div style="padding:10px 0;">
				<input type="file" id="fileExcelData" name="fileExcelData" style="display:inline-block;"/>
				<input type="button" class="btn green" value="上传" onclick="submitExcel();" style="padding: 3px 10px;" />
			</div>
			<a style="color:#aaa;" class="downloadLink" href="${request.getContextPath()}/files/ImportTemplate/sellPoolImport.xlsx">模版下载：卖盘池导入(模版).xlsx</a>
			<p id="errorInfo" ></p>
		</div>
	</div>
	<div class="page-header">
		<!--头部开始-->
		<#include "/include/top.html" />
		<!-- 头部信息结束 -->


		<!-- 头部菜单开始 -->
		<#include "/include/top_menu.html" />
		<!-- 头部菜单结束 -->
	</div>
	<!-- END HEADER -->


	<!-- BEGIN PAGE CONTAINER -->
	<div class="page-container">
		<!-- 内容开始 -->
		<div class="page-content">
			<div class="container-fluid">
				<!-- 当前位置提示开始 -->
				<ul class="page-breadcrumb breadcrumb">
					<li><a href="#">首页</a><i class="fa fa-circle"></i>
					<li class="active">撮合管理<i class="fa fa-circle"></i>
					<li class="active">卖盘池
				</ul>
				<!-- 当前位置提示结束 -->
				<div class="row margin-top-10">
					
					<#if Session['userInfo']['itemId'] != '26278' && Session['userInfo']['itemId'] != '26297' && Session['userInfo']['itemId'] != '26299'>
					<div class="col-md-12" >
						<div class="portlet light bordered">
							<div class="portlet-body" style="height: 13px;padding-top: 0px">
								<div style="float:left;width: 77%">
									<span>有色网报价：&nbsp;</span> <span
										style="font-family:'Arial Negreta', 'Arial';font-weight:700;font-size:13px;color:#333333;"
										id="itemName"></span> <span
										style="font-family:'Arial Normal', 'Arial';font-weight:400;font-size:13px;color:#333333;">￥</span>
									<span
										style="font-family:'Arial Normal', 'Arial';font-weight:400;font-size:14px;color:#D7000F;"
										id="price">00.00 </span> 
										<#if items.id == 26288>
											<span style="font-family:'Arial Normal', 'Arial';font-weight:400;font-size:13px;color:#333333;">元/千克&nbsp;</span>
										<#else>
											<span style="font-family:'Arial Normal', 'Arial';font-weight:400;font-size:13px;color:#333333;">元/吨&nbsp;</span>
										</#if>
									<span
										style="font-family:'Arial Normal', 'Arial';font-weight:400;font-size:13px;color:#333333;">&nbsp;SHFE:
									</span> <span
										style="font-family:'Arial Normal', 'Arial';font-weight:400;font-size:14px;color:#D7000F;"
										id="avg">00.00</span> <span
										style="font-family:'Arial Normal', 'Arial';font-weight:400;font-size:14px;color:#333333;">&nbsp;涨速:
									</span> <span
										style="font-family:'Arial Normal', 'Arial';font-weight:400;font-size:14px;color:#D7000F;"
										id="float"> </span> <span style="display: none" id="remind1">&nbsp;异动提醒&nbsp;
									</span> <span style="display: none" id="remind2"></span> <span
										style="font-family:'Arial Normal', 'Arial';font-weight:400;font-size:13px;color:#333333;">&nbsp;
										<a
										href="http://finance.sina.com.cn/futures/quotes/${productType}0.shtml"
										target='_blank'><i class="fa fa-bar-chart-o" onclick=""></i></a>
									</span>
								</div>
								<div
									style="float: right;width: 23%;text-align: right;padding-right: 18px;">
									<p>
										更新时间：<span id="updateTime"> </span>
									</p>
								</div>
							</div>
						</div>
					</div>
					</#if>
					<div class="col-md-12">
						<div class="portlet light bordered">
							<div class="portlet-body" style="height: 13px;padding-top: 0px">
								<div style="float: left;">
									视图： <a
										href="${request.getContextPath()}/dealMake/sellOrder.do?type=0">全部</a>|
									<a
										href="${request.getContextPath()}/dealMake/sellOrder.do?type=1">我的客户</a>|
									<a
										href="${request.getContextPath()}/dealMake/sellOrder.do?type=2">部门客户</a>
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-12">
						<div class="portlet light bordered">
							<div class="portlet-body">
								<div class="row">
									<div style="float: left;width:100px; margin-left: 15px;">
										<div class="btn-group pull-left">
											<a class="btn green dropdown-toggle"
												href="javascript:batchDelSellPool()">批量删除 </a>
										</div>
									</div>
									<form
										action="${request.getContextPath()}/dealMake/sellOrder.do"
										method="post">
										<div style="float: left;width: 62%">
											<div style="width:200px;float:left;">
												<select class="form-control" onchange="selectColumn()" name="parameter1" id="parameter1" >
													<option value="0">--选择筛选条件--</option>
													<option value="1"<#if parameter1 ==
														"1">selected</#if> >客户</option>
													<option value="2"<#if parameter1 ==
														"2">selected</#if> >产品</option>
													<option value="3"<#if parameter1 ==
														"3">selected</#if> >品牌</option>
													<option value="4"<#if parameter1 ==
														"4">selected</#if> >价格</option>
													<option value="5"<#if parameter1 ==
														"5">selected</#if> >库存</option>
													<option value="6"<#if parameter1 ==
														"6">selected</#if> >仓库</option>
													<option value="7"<#if parameter1 ==
														"7">selected</#if> >更新时间</option>
													<option value="8"<#if parameter1 ==
														"8">selected</#if> >订单</option>
													<option value="9"<#if parameter1 ==
														"9">selected</#if> >报价人</option>

												</select>
											</div>
											<div style="width:110px; float:left; margin-left:15px;">
												<select class="form-control" name="parameter2" id="parameter2">
													<option value="1"<#if parameter2 ==
														"1">selected</#if> >包含</option>
													<option value="2"<#if parameter2 ==
														"2">selected</#if> >不包含</option>
													<option value="3"<#if parameter2 ==
														"3">selected</#if> >等于</option>
													<option value="4"<#if parameter2 ==
														"4">selected</#if> >不等于</option>
													<option value="5"<#if parameter2 ==
														"5">selected</#if> >开始字符</option>
													<option value="6"<#if parameter2 ==
														"6">selected</#if> >结束字符</option>
													<option value="7"<#if parameter2 ==
														"7">selected</#if> >为空</option>
													<option value="8"<#if parameter2 ==
														"8">selected</#if> >不为空</option>
												</select>
											</div>
											<div class="col-md-3">
												<input type="text" class="form-control" name="parameter3" id="parameter3"
													value="${parameter3!''}">
											</div>
											<div class="col-md-2">
												<button class="btn green" type="submit">
													<i class="fa fa-search"></i> 搜索
												</button>
											</div>
										</div>
									</form>
									<div
										style="float: right;width: 28%;text-align: right;padding-right: 18px;">
										
										<a href="#" class="btn green baocun" href="javascript:void(0);">
											 保存编号
										</a>
										
										
										<a class="btn green"
											href="${request.getContextPath()}/dealMake/newSellPool.do">
											<i class="fa fa-plus"></i> 新建卖盘
										</a>
										<button class="btn green" id="btn_Import">
											<i class="fa fa-file-excel-o"></i> 导入
										</button>
										<button class="btn green" id="btn_Export"
											onclick="sellPoolExport();">
											<i class="fa fa-file-excel-o"></i> 导出
										</button>
									</div>
								</div>
								<div class="table-scrollable">
									<table
										class="table table-striped table-bordered table-advance table-hover ttTbl"
										id="myTable">
										<thead>
											<tr>
												<th class="table-checkbox"><input type="checkbox"
													class="group-checkable" data-set="#myTable .checkboxes" />
												</th>
												<th scope="col">编号</th>
												<th scope="col">客户</th>
												<th scope="col">产品</th> <#list itemAttrList as itemAttr>
												<th scope="col">${itemAttr.name}</th> </#list>
												<th scope="col">价格</th>
												<th scope="col">库存</th>
												<th scope="col">仓库</th>
												<th scope="col">更新时间</th>
												<th scope="col">订单</th>
												<th scope="col">报价人</th>
												<!-- <th scope="col">交易备注</th>-->
												<th scope="col">操作</th>
											</tr>
										</thead>
										<tbody>

											<#list sellPoolList as sellPool>
											<tr>
												<td><input type="checkbox" class="checkboxes"
													name="checkboxes" value="${sellPool.id?c}" /></td>
												<td title="只能输入0-99的整数">
													<input type="text" id="sortNum" name="sortNum" poolId = "${sellPool.id}"
													value="${sellPool.sortNum}" style="text-align: center;width: 30px "/ onchange="isPositiveNum(this)" >
													<input type="hidden" id="poolId" name="poolId" 
													value="${sellPool.id}" style="text-align: center;width: 30px "/>
												</td>
												<td>${sellPool.companyNm}</td>
												<td>${sellPool.itemsNm}</td> <#if sellPool.attrValues??>
												<#list itemAttrList as itemAttr>
												<td><#list sellPool.attrValues as Value> <#if
													Value?size gt 0> <#if itemAttr.name == Value.attrName >
													${Value.attrValue!''} </#if> </#if> </#list></td> </#list>
												</#if>
												<td><#if sellPool.priceType==0>实价</#if>
												<#if sellPool.priceType==1>升贴水</#if>
												${sellPool.price?string('#.##')}</td>
												<td>${sellPool.quantity}</td>
												<td>${sellPool.wareNm!''}</td>
												<td><#if sellPool.updatedat??>
													${sellPool.updatedat?string("yyyy-MM-dd HH:mm:ss")} <#else> </#if></td>
												<td><font color="red">${sellPool.orderNum}笔</font></td>
												<td>${sellPool.createdNm}</td>
												<!--  <td><#if sellPool.commands??> ${sellPool.commands?html}
													<#else> </#if></td> -->
												<td><a
													href="${request.getContextPath()}/buypool/toaddsellorder.do?sid=${sellPool.id?c}&poolType=1"
													class="btn btn-xs green"> 生成订单 </a> <a
													href="${request.getContextPath()}/dealMake/toupdateSellPool.do?sellPoolId=${sellPool.id?c}"
													class="btn btn-xs green"> 修改 </a> <#if sellPool.orderNum gt 0>
													<a href="javascript:viewOrders(${sellPool.id?c})"
													class="btn btn-xs green">查看订单 </a> </#if> 
													<#if sellPool.mallSaleId??>
													  <#else>
													  <a href="javascript:fabu(${sellPool.id})"
                                             	   	class="btn btn-xs green"> 发布 </a> 
                                             	   </#if>
													<a class="btn btn-xs green"
													href="${request.getContextPath()}/dealMake/delSellPool.do?id=${sellPool.id?c}">
														隐藏 </a></td>
											</tr>
											</#list>
										</tbody>
									</table>
								</div>
								<div style="width:80%;margin:0 auto;">
									<div id="kkpager"></div>
									<input type="hidden" value="#{totalPage}" id="totalPage">
									<input type="hidden" value="#{totalRecords}" id="totalRecords">
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- END PAGE CONTAINER -->


	<!-- 底部开始 -->
	<#include "/include/foot.html" />
	<!-- 底部结束 -->

	<!--[if lt IE 9]>
<script src="${request.getContextPath()}/Public/assets/global/plugins/respond.min.js"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/excanvas.min.js"></script>
<![endif]-->
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery-migrate.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery-ui.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/js/bootstrap.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery.blockui.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery.cokie.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/uniform/jquery.uniform.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/jquery-notific8/jquery.notific8.min.js"></script>

	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"
		type="text/javascript"></script>

	<script
		src="${request.getContextPath()}/Public/assets/global/scripts/metronic.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/admin/scripts/layout.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/global/plugins/kkpager.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/admin/scripts/commonUtils.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/admin/scripts/priceFloat.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/admin/scripts/tc.min.js"
		type="text/javascript"></script>
	<script
		src="${request.getContextPath()}/Public/assets/admin/scripts/ajaxfileupload.js"
		type="text/javascript"></script>
	<script>
		function orderDetail(orderId) {
			CommonUtils.editModal(BASE_URL+ "/customerDetail/orderRecord/orderDetail.do?orderId="+ orderId, 800);
		}
		jQuery(document).ready(function() {
		 	selectColumn();
			Metronic.init(); // init metronic core componets
			Layout.init(); // init layout
			CommonUtils.checkInit();
			PriceFloat.getPriceProduct();
			$("#btn_Import").click(function() {
				$("#errorInfo").html("");
				popWin("div_Import");
			});
		});
		recordDate();
		
		//初始化日期
		function recordDate() {
			var nowDate = new Date();
			//$('#date-picker').attr("date-date",nowDate.getFullYear()+"/"+parseInt(nowDate.getMonth()+1)+"/"+nowDate.getDate());
			$('.date-picker').datepicker({
				autoclose : true
			});
		}

		//初始化分页插件
		function getParameter(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if (r != null)
				return unescape(r[2]);
			return null;
		} 

		//init
		$(function() {

			//循坏15秒刷新
			window.setInterval(PriceFloat.getPriceProduct, 15 * 1000);

			var totalPage = $('#totalPage').val();
			var totalRecords = $('#totalRecords').val();

			var pageNo = getParameter('pno');
			if (!pageNo) {
				pageNo = 1;
			}
			//生成分页
			//有些参数是可选的，比如lang，若不传有默认值
			kkpager.generPageHtml({
				pno : pageNo,
				//总页码
				total : totalPage,
				//总数据条数
				totalRecords : totalRecords,

				getLink : function(n) {
					var temp = $("#parameter3").val();
					//var parameter3 = encodeURI(encodeURI(temp));
					//var parameter3 = URLDecoder.decode($("#parameter3").val(), "UTF-8");
					//alert(parameter3);
					return this.hrefFormer + this.hrefLatter + "?pno=" +n+"&parameter1="+$("#parameter1").val()
					+"&parameter2="+$("#parameter2").val()+"&parameter3="+encodeURI(encodeURI(temp));
				}
			});
		});
		
		//提交excel上传的form表单
		function submitExcel() {
			var fileName = $("#fileExcelData").val();
			if (fileName.length == 0) {
				alert("请选择需导入的文件！")
				return;
			}
			var extName = fileName.split('.')[(fileName.split('.').length - 1)];
			if (extName.toLowerCase() != "xls"
				&& extName.toLowerCase() != "xlsx") {
					alert("请导入excel文件，不支持其他格式！");
					return;
			}
			$.ajaxFileUpload({
				url : "${request.getContextPath()}/dealMake/importExcel.do", //用于文件上传的服务器端请求地址
				secureuri : false, //是否需要安全协议，一般设置为false
				fileElementId : "fileExcelData", //文件上传域的ID
				dataType : "JSON", //返回值类型 一般设置为json
				success : function(data, status){ //服务器成功响应处理函数
					$("#errorInfo").html(data);
					if (data.indexOf("数据导入成功！") > 0)
						window.location = "${request.getContextPath()}/dealMake/sellOrder.do";
				},
				error : function(data, status, e){//服务器响应失败处理函数
					alert(e);
				}
			})
		}

		function sellPoolExport() {
			var checks = CommonUtils.getCheckedBoxs().join(",");
			var parameter1=$("#parameter1").val();
			var parameter2=$("#parameter2").val();
			var parameter3=encodeURI(encodeURI($("#parameter3").val()));
			//var parameter3=$("#parameter3").val();
			var urlParam="?ids="+checks+"&parameter1="+parameter1+"&parameter2="+parameter2+"&parameter3="+parameter3;

			window.location = "${request.getContextPath()}/dealMake/sellPoolExport.do"
					+ urlParam;
		}

		function batchDelSellPool() {
			CommonUtils
					.doExecute('${request.getContextPath()}/dealMake/delAll.do');
		}
		function viewOrders(sellPoolId) {

			CommonUtils.editModal(
					'${request.getContextPath()}/dealMake/viewOrder.do?sellPoolId='
							+ sellPoolId, 600);

			//orderDetail(109);
		}
		
		function selectColumn() {
			var value = $("#parameter1").val();
			
			if (value == 7) {
				$('#parameter3').bind("click", function(){WdatePicker();});
			} else {
				$('#parameter3').unbind("click");
			}
		}
		
		function  fabu(sellId){
			var sortNum;
			$("input[name='sortNum']").each(
					function(){
						var poolId = $(this).attr("poolId");
						if(poolId == sellId){
							sortNum = $(this).val();
						}
					}
			)
			if(window.confirm('你确定要将该卖盘发布到商城吗？')){
				$.ajax({
					url : "${request.getContextPath()}/dealMake/publishSellPool.do?sellPoolId="+sellId+"&sortNum="+sortNum,
					type : "post",
					dataType:"json",
					async: false,
					data :{"id":$("#companyid").val()}, //联动查询的字符
					success : function(data) {
						if(data.code=="ok"){
							alert(data.msg);
							window.location.href="${request.getContextPath()}/dealMake/sellOrder.do";
							
						}else{
							alert(data.msg);
						}
					}
				});
			}
		}
		
		//保存卖盘编号，用于商城排序 
		$(".baocun").bind("click",function(){
			//alert("保存商城编号");
			var sortNums = "";
			var poolIds = "";
			$("input[name='sortNum']").each(
				function(){
					sortNums = sortNums+$(this).val()+",";
				}
			)
			$("input[name='poolId']").each(
				function(){
					poolIds = poolIds+$(this).val()+",";
				}
			)
			//alert(sortNums+"|||||"+poolIds);
			$.ajax({
				url : "${request.getContextPath()}/dealMake/updateSellPoolSortNum.do",
				type : "post",
				dataType : 'JSON',
				data : {"sortNums" : sortNums,"poolIds":poolIds},
				success : function(result) {
					if(result.code == "OK"){
						alert(result.msg);
						window.location.href="${request.getContextPath()}/dealMake/sellOrder.do";
					}
					else{
						alert(result.msg);
						window.location.href="${request.getContextPath()}/dealMake/sellOrder.do";
					}
				}
			});			
		});
		
		//是否为正整数   
		function isPositiveNum(object){
			var re = /^[0-9]*[0-9][0-9]*$/ ; 
			var temp = re.test(object.value);
			if(temp != true){//不是正整数
				alert("只能输入0-99的正整数！");
				$(object).val(0);
			}
			if(object.value > 99){
				alert("只能输入0-99的正整数！");
				$(object).val(0);
			}
		} 
	</script>
</body>
</html>